package com.paly.client.api;

import annotation.ApiServer;
import com.paly.client.model.User;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

@ApiServer("http://localhost:8080/user")
@Component
public interface IUserApi {
    @GetMapping("/")
    Flux<User> getAll();

    @PostMapping("/")
    Mono<User> crete(@RequestBody Mono<User> user);

    @GetMapping(value = "/getAllStream", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    Flux<User> getStreamAll();

    @DeleteMapping("/{id}")
    Mono<Void> delete(@PathVariable("id") String id);

    @PutMapping("/{id}")
    Mono<User> update(@PathVariable("id") String id, @RequestBody Mono<User> user);

    @GetMapping("/{id}")
    Mono<User> findById(@PathVariable("id") String id);

    @GetMapping(value = "/stream/age/{start}/{end}", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    Flux<User> getUserByAgeStream(@PathVariable("start") int start, @PathVariable("end") int end);

    @GetMapping(value = "/age/{start}/{end}")
    Flux<User> getUserByAge(@PathVariable("start") int start, @PathVariable("end") int end);
}
